<template>
  <div id="app">
<!--      获取用户列表-->


    <div style="margin:30px"></div>
    <el-input v-model="searchs" @change="search" placeholder="请输入内容"></el-input>

    <template>
      <el-table
          :data="users"
          style="width: 100%">
        <el-table-column
            prop="nickname"
            label="用户名"
            width="150">
        </el-table-column>
        <el-table-column
            label="头像"
            width="100">
<!--      头像    图片-->
          <el-image
              style="width: 50px; height: 50px"
              :src="head_portrait"
              :preview-src-list="head_portrait">
          </el-image>
        </el-table-column>
        <el-table-column
            prop="id"
            label="用户ID"
            width="80">
        </el-table-column>
        <el-table-column
            prop="sex"
            label="性别"
            width="50">
        </el-table-column>
        <el-table-column
            prop="status"
            label="审核状态"
            width="50">
        </el-table-column>
        <el-table-column
            prop="create_time"
            label="创建时间"
            width="300">
        </el-table-column>
        <el-table-column
            prop="openid"
            label="openid"
            width="300">
        </el-table-column>
      </el-table>
    </template>





    <div class="block">
      <el-pagination
          @current-change="handleCurrentChange"
          layout="prev, pager, next"
          :total="1000">
      </el-pagination>
    </div>

    <div style="margin:30px"></div>




  </div>
</template>

<script>
export default {
  data() {
    return {
      users: [],
      page: 1,
      keywords: '',
      searchs: '',

    }
  },
  created() {
    this.getUserList()
  },
  methods: {
    // 获取用户列表
    async getUserList() {
        await this.$http.post("/Admin/userList", {
          page: this.page,
          limit: 10,
          keywords: this.keywords,
        }).then(res =>{
          // console.log(res)
          this.users = res.data.data;
        }).catch(err => {
          log.error("getuserList err => ",err)
        })
    },


    // 操作当前页面
    handleCurrentChange(val) {
      // console.log(val)
      this.page = val;
    },
    search() {
      this.keywords = this.searchs
    }

  },


  watch: {
    page: function () {
      this.getUserList();
    },
    keywords: function () {
      this.getUserList();
    },
  }

}
</script>

<style lang="less" scoped>

</style>
